Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(google-genai): Check Google Generative AI Structured Output #7293

Merged

Conversation

BaharChidem
Copy link
Contributor

@BaharChidem BaharChidem commented Nov 29, 2024

Fixes #6901

This PR addresses Issue #6901, which occurred when attempting to generate structured output using Google's Generative AI. The initial fix for this issue was implemented in PR #7213, and this PR extends the coverage by adding dedicated test cases to ensure the fix's correctness and stability.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 29, 2024
Copy link

vercel bot commented Nov 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Dec 3, 2024 11:29pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Dec 3, 2024 11:29pm

@jacoblee93 jacoblee93 changed the title Check Google Generative AI Structured Output feat(google-genai): Check Google Generative AI Structured Output Dec 3, 2024
temperature: 0.7,
});
const structuredLlm = model.withStructuredOutput(schema);
const request = "Generate structured data where age is a number.";
Copy link
Collaborator

@jacoblee93 jacoblee93 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like a reliable test - shouldn't we expect an error to be thrown? Going to skip this one.

expect(result.details).toHaveProperty("address");
});

test("Google AI - Handle missing required fields", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above - this test will pass if the request doesn't throw an error.

expect(result).toHaveProperty("email");
});

test("Google AI - Throw error for empty response", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems those tests in the above comments were not throwing errors at all

Removed for now, will merge the rest. Thank you!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Dec 3, 2024
@jacoblee93 jacoblee93 merged commit 24315a1 into langchain-ai:main Dec 3, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Gen AI Structured Output Error
3 participants